package cn.cy.behavior.command.pattern;

/**
 * @author yangxq
 * @Date 2025-05-08
 * @desc
 */
public class PatternClient {

    public static void main(String[] args) {
        // 创建接收者
        Light light = new Light();

        // 创建具体命令
        Command turnOnCommand = new TurnOnLightCommand(light);
        Command increaseBrightnessCommand = new IncreaseBrightnessCommand(light);
        Command decreaseBrightnessCommand = new DecreaseBrightnessCommand(light);
        Command turnOffCommand = new TurnOffLightCommand(light);

        // 创建调用者
        RemoteControl remoteControl = new RemoteControl();

        // 设置开灯命令并执行
        remoteControl.setCommand(turnOnCommand);
        remoteControl.pressButton();

        // 设置增加亮度命令并执行
        remoteControl.setCommand(increaseBrightnessCommand);
        remoteControl.pressButton();
        remoteControl.pressButton();

        // 设置减少亮度命令并执行
        remoteControl.setCommand(decreaseBrightnessCommand);
        remoteControl.pressButton();

        // 设置关灯命令并执行
        remoteControl.setCommand(turnOffCommand);
        remoteControl.pressButton();
    }

}
